using UnityEngine;
using System.Collections;

public class Collision : MonoBehaviour {

	public Transform explosion;
	
	void OnTriggerEnter(Collider other){
		//Colisão entre o inimigo 
		if (gameObject.CompareTag("Enemy") == true)
		{
			//e o jogador
			if(other.gameObject.tag == "Player")
			{
				Destroy(gameObject);
				GameManager.Instance.LostLife();
			}
		}
		//Colisão entre o tiro inimigo
		else if (gameObject.CompareTag("EnemyShot") == true)
		{
			//e o jogador
			if(other.gameObject.tag == "Player")
			{
				//Destroy(other.gameObject);
				Destroy(gameObject);
				//GameManager.GM.LostGame();
				GameManager.Instance.LostLife();
			}
			//e o tiro do jogador
			else if (other.gameObject.tag == "Shot")
			{ 
				Destroy(other.gameObject);
				Destroy(gameObject);
			}
		}
		//colisao entre o tiro do jogador
		else
		{
			//e o inimigo
			if(other.gameObject.tag == "Enemy")
			{	
				GameManager.Instance.DestroyEnemy();
		    	Destroy(other.gameObject);							
				Destroy(gameObject);
					
			}
			//e o tiro inimigo
			else if (other.gameObject.tag == "EnemyShot")
			{ 
				Destroy(other.gameObject);
				Destroy(gameObject);
			}
		}
	}
}
